<script>
	export default {
		onLaunch: function() {
			// 检测网络状态
			this.checkNetworkStatus();
			
			// 获取token
			const token = uni.getStorageSync('token');
			if(token){
				uni.switchTab({ url: '/pages/tabs/chat' })
			}
		},
		onShow: function() {
			
		},
		onHide: function() {
			
		},
		methods: {
			checkNetworkStatus() {
				// 获取当前网络类型
				uni.getNetworkType({
					success: (res) => {
						if (res.networkType === 'none') {
							uni.showToast({
								title: '无网络连接，请检查网络设置',
								icon: 'none'
							});
						}
					}
				});

				// 监听网络状态变化
				uni.onNetworkStatusChange((res) => {
					if (!res.isConnected) {
						uni.showToast({
							title: '网络连接已断开，请检查网络设置',
							icon: 'none'
						});
					} else if (res.networkType === '2g' || res.networkType === '3g') {
						uni.showToast({
							title: '网络信号较弱，建议切换到更好的网络',
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';
	/* #ifndef APP-NVUE */

	/* #endif */
	.example-info {
		font-size: 14px;
		color: #333;
		padding: 10px;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}

	page {
		font-size: 28rpx !important;

		.container {
			padding: 32rpx;
		}
	}

	//flex公共样式
	.flex {
		display: flex;
	}

	.flex-1 {
		flex: 1;
	}

	.flex-wrap {
		flex-wrap: wrap;
	}

	.flex-center {
		justify-content: center;
		align-items: center;
	}

	.flex-between {
		justify-content: space-between;
		align-items: center;
	}

	.flex-column {
		flex-direction: column;
	}

	.flex-column-center {
		justify-content: center;
		align-items: center;
	}

	.flex-column-between {
		justify-content: space-between;
		align-items: center;
	}

	.flex-column-start {
		justify-content: flex-start;
		align-items: flex-start;
	}

	.flex-column-end {
		justify-content: flex-end;
		align-items: flex-end;
	}

	.flex-column-around {
		justify-content: space-around;
		align-items: center;
	}

	.flex-column-between {
		justify-content: space-between;
		align-items: center;
	}

	.flex-column-start {
		justify-content: flex-start;
		align-items: flex-start;
	}

	.flex-column-end {
		justify-content: flex-end;
		align-items: flex-end;
	}

	.flex-column-around {
		justify-content: space-around;
		align-items: center;
	}

	.flex-column-between {
		justify-content: space-between;
		align-items: center;
	}

	.flex-column-start {
		justify-content: flex-start;
		align-items: flex-start;
	}

	.flex-column-end {
		justify-content: flex-end;
		align-items: flex-end;
	}

	.flex-start-center{
		justify-content: flex-start;
		align-items: center;
	}

	.flex-end-center{
		justify-content: flex-end;
		align-items: center;
	}
</style>